package com.raymond.smgp.msg.request;

import com.raymond.client.msg.AbstractMessage;
import com.raymond.smgp.enums.CommandIdType;

/**
 * 连接请求
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-08-05 11:26
 */
public class ConnectRequestMessage extends AbstractMessage {
    /**
     * 源地址，此处为SP_Id，即SP的企业代码。
     */
    private String clientId;
    /**
     * 用于鉴别源地址。其值通过单向MD5 hash计算得出，表示如下：
     * AuthenticatorSource =
     * MD5（Source_Addr+9 字节的0 +shared secret+timestamp）
     * Shared secret 由中国移动与源地址实体事先商定，timestamp格式为：MMDDHHMMSS，即月日时分秒，10位。
     */
    private byte[] authenticatorClient;

    private int loginMode = 2;

    /**
     * 双方协商的版本号(高位4bit表示主版本号,低位4bit表示次版本号)，对于3.0的版本，高4bit为3，低4位为0
     */
    private short version = 0x30;
    /**
     * 时间戳的明文,由客户端产生,格式为MMDDHHMMSS，即月日时分秒，10位数字的整型，右对齐 。
     */
    private int timestamp = 0;

    public ConnectRequestMessage(int sequenceId) {
        super(sequenceId);
    }

    @Override
    public int getCommandId() {
        return CommandIdType.CONNECT_REQUEST.getCommandId();
    }

    public String getClientId() {
        return clientId;
    }

    public void setClientId(String clientId) {
        this.clientId = clientId;
    }

    public byte[] getAuthenticatorClient() {
        return authenticatorClient;
    }

    public void setAuthenticatorClient(byte[] authenticatorClient) {
        this.authenticatorClient = authenticatorClient;
    }

    public int getLoginMode() {
        return loginMode;
    }

    public void setLoginMode(int loginMode) {
        this.loginMode = loginMode;
    }

    public short getVersion() {
        return version;
    }

    public void setVersion(short version) {
        this.version = version;
    }

    public int getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(int timestamp) {
        this.timestamp = timestamp;
    }
}
